/*
** Lua binding: http
** Generated automatically by tolua++-1.0.92 on 03/17/16 16:43:39.
*/

#ifndef __cplusplus
#include "stdlib.h"
#endif
#include "string.h"

#include "tolua++.h"

/* Exported function */
TOLUA_API int  tolua_http_open (lua_State* tolua_S);

#include "node/net/http/http_request.h"
#include "node/net/http/http_response.h"
#include "node/net/http/http_server.h"
#include "node/net/http/http_worker.h"
using HttpRequest = ::node::http::HttpRequest;
using HttpResponse = ::node::http::HttpResponse;
using HttpServer = ::node::http::HttpServer;
using HTTP_REQUEST_CALLBACK = ::node::http::HTTP_REQUEST_CALLBACK;
using HttpWorker = ::node::http::HttpWorker;

class HttpRequestCallbackWrapper
{
public:
    HttpRequestCallbackWrapper(lua_State* L, int lua_callback)
        : L_(L)
        , lua_callback_(lua_callback)
    {

    }

    static void OnHttpRequest(HttpRequest *req, HttpResponse *resp, void *arg)
    {
        HttpRequestCallbackWrapper *wrapper = static_cast<HttpRequestCallbackWrapper*>(arg);
        assert(wrapper);
        // call lua function
        lua_rawgeti(wrapper->L_, LUA_REGISTRYINDEX, wrapper->lua_callback_);
        tolua_pushusertype(wrapper->L_, req, "HttpRequest");
        tolua_pushusertype(wrapper->L_, resp, "HttpResponse");
        lua_call(wrapper->L_, 2, 0);
    }

private:
    lua_State* L_;
    int lua_callback_;
};

/* function to release collected object via destructor */
#ifdef __cplusplus

static int tolua_collect_HttpWorker (lua_State* tolua_S)
{
 HttpWorker* self = (HttpWorker*) tolua_tousertype(tolua_S,1,0);
    Mtolua_delete(self);
    return 0;
}

static int tolua_collect_HttpServer (lua_State* tolua_S)
{
 HttpServer* self = (HttpServer*) tolua_tousertype(tolua_S,1,0);
    Mtolua_delete(self);
    return 0;
}
#endif


/* function to register type */
static void tolua_reg_types (lua_State* tolua_S)
{
 tolua_usertype(tolua_S,"HttpServer");
 tolua_usertype(tolua_S,"HTTP_REQUEST_CALLBACK");
 tolua_usertype(tolua_S,"HttpResponse");
 tolua_usertype(tolua_S,"HttpWorker");
 tolua_usertype(tolua_S,"HttpRequest");
}

/* method: get_uri of class  HttpRequest */
#ifndef TOLUA_DISABLE_tolua_http_HttpRequest_get_uri00
static int tolua_http_HttpRequest_get_uri00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"const HttpRequest",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  const HttpRequest* self = (const HttpRequest*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'get_uri'", NULL);
#endif
  {
   const char* tolua_ret = (const char*)  self->get_uri();
   tolua_pushstring(tolua_S,(const char*)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'get_uri'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: get_input_size of class  HttpRequest */
#ifndef TOLUA_DISABLE_tolua_http_HttpRequest_get_input_size00
static int tolua_http_HttpRequest_get_input_size00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"const HttpRequest",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  const HttpRequest* self = (const HttpRequest*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'get_input_size'", NULL);
#endif
  {
   unsigned int tolua_ret = (unsigned int)  self->get_input_size();
   tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'get_input_size'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: Read of class  HttpRequest */
#ifndef TOLUA_DISABLE_tolua_http_HttpRequest_Read00
static int tolua_http_HttpRequest_Read00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HttpRequest",0,&tolua_err) ||
     !tolua_isstring(tolua_S,2,0,&tolua_err) ||
     !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,4,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpRequest* self = (HttpRequest*)  tolua_tousertype(tolua_S,1,0);
  char* buffer = ((char*)  tolua_tostring(tolua_S,2,0));
  int size = ((int)  tolua_tonumber(tolua_S,3,0));
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Read'", NULL);
#endif
  {
   int tolua_ret = (int)  self->Read(buffer,size);
   tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'Read'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: get_header of class  HttpRequest */
#ifndef TOLUA_DISABLE_tolua_http_HttpRequest_get_header00
static int tolua_http_HttpRequest_get_header00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HttpRequest",0,&tolua_err) ||
     !tolua_isstring(tolua_S,2,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,3,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpRequest* self = (HttpRequest*)  tolua_tousertype(tolua_S,1,0);
  const char* name = ((const char*)  tolua_tostring(tolua_S,2,0));
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'get_header'", NULL);
#endif
  {
   const char* tolua_ret = (const char*)  self->get_header(name);
   tolua_pushstring(tolua_S,(const char*)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'get_header'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: get_host of class  HttpRequest */
#ifndef TOLUA_DISABLE_tolua_http_HttpRequest_get_host00
static int tolua_http_HttpRequest_get_host00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"const HttpRequest",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  const HttpRequest* self = (const HttpRequest*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'get_host'", NULL);
#endif
  {
   const char* tolua_ret = (const char*)  self->get_host();
   tolua_pushstring(tolua_S,(const char*)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'get_host'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: get_port of class  HttpRequest */
#ifndef TOLUA_DISABLE_tolua_http_HttpRequest_get_port00
static int tolua_http_HttpRequest_get_port00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"const HttpRequest",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  const HttpRequest* self = (const HttpRequest*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'get_port'", NULL);
#endif
  {
   const int tolua_ret = (const int)  self->get_port();
   tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'get_port'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: get_path of class  HttpRequest */
#ifndef TOLUA_DISABLE_tolua_http_HttpRequest_get_path00
static int tolua_http_HttpRequest_get_path00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"const HttpRequest",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  const HttpRequest* self = (const HttpRequest*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'get_path'", NULL);
#endif
  {
   const char* tolua_ret = (const char*)  self->get_path();
   tolua_pushstring(tolua_S,(const char*)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'get_path'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: get_query of class  HttpRequest */
#ifndef TOLUA_DISABLE_tolua_http_HttpRequest_get_query00
static int tolua_http_HttpRequest_get_query00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"const HttpRequest",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  const HttpRequest* self = (const HttpRequest*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'get_query'", NULL);
#endif
  {
   const char* tolua_ret = (const char*)  self->get_query();
   tolua_pushstring(tolua_S,(const char*)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'get_query'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: AddHeader of class  HttpResponse */
#ifndef TOLUA_DISABLE_tolua_http_HttpResponse_AddHeader00
static int tolua_http_HttpResponse_AddHeader00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HttpResponse",0,&tolua_err) ||
     !tolua_isstring(tolua_S,2,0,&tolua_err) ||
     !tolua_isstring(tolua_S,3,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,4,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpResponse* self = (HttpResponse*)  tolua_tousertype(tolua_S,1,0);
  const char* name = ((const char*)  tolua_tostring(tolua_S,2,0));
  const char* value = ((const char*)  tolua_tostring(tolua_S,3,0));
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'AddHeader'", NULL);
#endif
  {
   bool tolua_ret = (bool)  self->AddHeader(name,value);
   tolua_pushboolean(tolua_S,(bool)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'AddHeader'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: Write of class  HttpResponse */
#ifndef TOLUA_DISABLE_tolua_http_HttpResponse_Write00
static int tolua_http_HttpResponse_Write00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HttpResponse",0,&tolua_err) ||
     !tolua_isstring(tolua_S,2,0,&tolua_err) ||
     !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,4,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpResponse* self = (HttpResponse*)  tolua_tousertype(tolua_S,1,0);
  const char* data = ((const char*)  tolua_tostring(tolua_S,2,0));
  int size = ((int)  tolua_tonumber(tolua_S,3,0));
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Write'", NULL);
#endif
  {
   bool tolua_ret = (bool)  self->Write(data,size);
   tolua_pushboolean(tolua_S,(bool)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'Write'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: WritePrintf of class  HttpResponse */
#ifndef TOLUA_DISABLE_tolua_http_HttpResponse_WritePrintf00
static int tolua_http_HttpResponse_WritePrintf00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HttpResponse",0,&tolua_err) ||
     !tolua_isstring(tolua_S,2,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,3,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpResponse* self = (HttpResponse*)  tolua_tousertype(tolua_S,1,0);
  const char* format = ((const char*)  tolua_tostring(tolua_S,2,0));
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'WritePrintf'", NULL);
#endif
  {
   bool tolua_ret = (bool)  self->WritePrintf(format);
   tolua_pushboolean(tolua_S,(bool)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'WritePrintf'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: End of class  HttpResponse */
#ifndef TOLUA_DISABLE_tolua_http_HttpResponse_End00
static int tolua_http_HttpResponse_End00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HttpResponse",0,&tolua_err) ||
     !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
     !tolua_isstring(tolua_S,3,0,&tolua_err) ||
     !tolua_isstring(tolua_S,4,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,5,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpResponse* self = (HttpResponse*)  tolua_tousertype(tolua_S,1,0);
  int code = ((int)  tolua_tonumber(tolua_S,2,0));
  const char* reason = ((const char*)  tolua_tostring(tolua_S,3,0));
  const char* data = ((const char*)  tolua_tostring(tolua_S,4,0));
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'End'", NULL);
#endif
  {
   self->End(code,reason,data);
  }
 }
 return 0;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'End'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: EndError of class  HttpResponse */
#ifndef TOLUA_DISABLE_tolua_http_HttpResponse_EndError00
static int tolua_http_HttpResponse_EndError00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HttpResponse",0,&tolua_err) ||
     !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
     !tolua_isstring(tolua_S,3,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,4,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpResponse* self = (HttpResponse*)  tolua_tousertype(tolua_S,1,0);
  int code = ((int)  tolua_tonumber(tolua_S,2,0));
  const char* reason = ((const char*)  tolua_tostring(tolua_S,3,0));
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'EndError'", NULL);
#endif
  {
   self->EndError(code,reason);
  }
 }
 return 0;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'EndError'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: new of class  HttpServer */
#ifndef TOLUA_DISABLE_tolua_http_HttpServer_new00
static int tolua_http_HttpServer_new00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertable(tolua_S,1,"HttpServer",0,&tolua_err) ||
     !tolua_isstring(tolua_S,2,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,3,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  const char* doc_root = ((const char*)  tolua_tostring(tolua_S,2,0));
  {
   HttpServer* tolua_ret = (HttpServer*)  Mtolua_new((HttpServer)(doc_root));
    tolua_pushusertype(tolua_S,(void*)tolua_ret,"HttpServer");
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: new_local of class  HttpServer */
#ifndef TOLUA_DISABLE_tolua_http_HttpServer_new00_local
static int tolua_http_HttpServer_new00_local(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertable(tolua_S,1,"HttpServer",0,&tolua_err) ||
     !tolua_isstring(tolua_S,2,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,3,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  const char* doc_root = ((const char*)  tolua_tostring(tolua_S,2,0));
  {
   HttpServer* tolua_ret = (HttpServer*)  Mtolua_new((HttpServer)(doc_root));
    tolua_pushusertype(tolua_S,(void*)tolua_ret,"HttpServer");
    tolua_register_gc(tolua_S,lua_gettop(tolua_S));
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: delete of class  HttpServer */
#ifndef TOLUA_DISABLE_tolua_http_HttpServer_delete00
static int tolua_http_HttpServer_delete00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HttpServer",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpServer* self = (HttpServer*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
#endif
  HttpRequestCallbackWrapper *wrapper = static_cast<HttpRequestCallbackWrapper*>(self->get_user_data());
  if (wrapper) {
      delete wrapper;
  }
  Mtolua_delete(self);
 }
 return 0;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: Start of class  HttpServer */
#ifndef TOLUA_DISABLE_tolua_http_HttpServer_Start00
static int tolua_http_HttpServer_Start00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HttpServer",0,&tolua_err) ||
     !tolua_isstring(tolua_S,2,0,&tolua_err) ||
     !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,4,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpServer* self = (HttpServer*)  tolua_tousertype(tolua_S,1,0);
  const char* host = ((const char*)  tolua_tostring(tolua_S,2,0));
  int port = ((int)  tolua_tonumber(tolua_S,3,0));
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Start'", NULL);
#endif
  {
   bool tolua_ret = (bool)  self->Start(host,port);
   tolua_pushboolean(tolua_S,(bool)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'Start'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: Stop of class  HttpServer */
#ifndef TOLUA_DISABLE_tolua_http_HttpServer_Stop00
static int tolua_http_HttpServer_Stop00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HttpServer",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpServer* self = (HttpServer*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Stop'", NULL);
#endif
  {
   self->Stop();
  }
 }
 return 0;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'Stop'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: Run of class  HttpServer */
#ifndef TOLUA_DISABLE_tolua_http_HttpServer_Run00
static int tolua_http_HttpServer_Run00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HttpServer",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpServer* self = (HttpServer*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Run'", NULL);
#endif
  {
   self->Run();
  }
 }
 return 0;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'Run'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: set_user_data of class  HttpServer */
#ifndef TOLUA_DISABLE_tolua_http_HttpServer_set_user_data00
static int tolua_http_HttpServer_set_user_data00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HttpServer",0,&tolua_err) ||
     !tolua_isuserdata(tolua_S,2,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,3,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpServer* self = (HttpServer*)  tolua_tousertype(tolua_S,1,0);
  void* user_data = ((void*)  tolua_touserdata(tolua_S,2,0));
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'set_user_data'", NULL);
#endif
  {
   self->set_user_data(user_data);
  }
 }
 return 0;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'set_user_data'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: set_request_callback of class  HttpServer */
#ifndef TOLUA_DISABLE_tolua_http_HttpServer_set_request_callback00
static int tolua_http_HttpServer_set_request_callback00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
    tolua_Error tolua_err;
    if (
        !tolua_isusertype(tolua_S, 1, "HttpServer", 0, &tolua_err) ||
        (tolua_isvaluenil(tolua_S, 2, &tolua_err)
        || !lua_isfunction(tolua_S, 2)) ||
        !tolua_isnoobj(tolua_S, 3, &tolua_err)
        )
        goto tolua_lerror;
    else
#endif
    {
        HttpServer* self = (HttpServer*)tolua_tousertype(tolua_S, 1, 0);
        HttpRequestCallbackWrapper *wrapper = static_cast<HttpRequestCallbackWrapper*>(self->get_user_data());
        if (wrapper != NULL) {
            tolua_error(tolua_S, "#ferror in function 'set_request_callback', callback already set", &tolua_err);
            return 0;
        }
        wrapper = new HttpRequestCallbackWrapper(tolua_S, luaL_ref(tolua_S, LUA_REGISTRYINDEX));
        if (wrapper == NULL) {
            tolua_error(tolua_S, "#ferror in function 'set_request_callback', alloc callback wrapper failed", &tolua_err);
            return 0;
        }
        self->set_user_data(wrapper);
#ifndef TOLUA_RELEASE
        if (!self) tolua_error(tolua_S, "invalid 'self' in function 'set_request_callback'", NULL);
#endif
        {
            self->set_request_callback(&HttpRequestCallbackWrapper::OnHttpRequest);
        }
    }
    return 0;
#ifndef TOLUA_RELEASE
tolua_lerror :
    tolua_error(tolua_S, "#ferror in function 'set_request_callback'.", &tolua_err);
    return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: new of class  HttpWorker */
#ifndef TOLUA_DISABLE_tolua_http_HttpWorker_new00
static int tolua_http_HttpWorker_new00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertable(tolua_S,1,"HttpWorker",0,&tolua_err) ||
     !tolua_isusertype(tolua_S,2,"HttpServer",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,3,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpServer* serv = ((HttpServer*)  tolua_tousertype(tolua_S,2,0));
  {
   HttpWorker* tolua_ret = (HttpWorker*)  Mtolua_new((HttpWorker)(serv));
    tolua_pushusertype(tolua_S,(void*)tolua_ret,"HttpWorker");
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: new_local of class  HttpWorker */
#ifndef TOLUA_DISABLE_tolua_http_HttpWorker_new00_local
static int tolua_http_HttpWorker_new00_local(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertable(tolua_S,1,"HttpWorker",0,&tolua_err) ||
     !tolua_isusertype(tolua_S,2,"HttpServer",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,3,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpServer* serv = ((HttpServer*)  tolua_tousertype(tolua_S,2,0));
  {
   HttpWorker* tolua_ret = (HttpWorker*)  Mtolua_new((HttpWorker)(serv));
    tolua_pushusertype(tolua_S,(void*)tolua_ret,"HttpWorker");
    tolua_register_gc(tolua_S,lua_gettop(tolua_S));
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: delete of class  HttpWorker */
#ifndef TOLUA_DISABLE_tolua_http_HttpWorker_delete00
static int tolua_http_HttpWorker_delete00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HttpWorker",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpWorker* self = (HttpWorker*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
#endif
  Mtolua_delete(self);
 }
 return 0;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: Start of class  HttpWorker */
#ifndef TOLUA_DISABLE_tolua_http_HttpWorker_Start00
static int tolua_http_HttpWorker_Start00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HttpWorker",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpWorker* self = (HttpWorker*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Start'", NULL);
#endif
  {
   bool tolua_ret = (bool)  self->Start();
   tolua_pushboolean(tolua_S,(bool)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'Start'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* method: Join of class  HttpWorker */
#ifndef TOLUA_DISABLE_tolua_http_HttpWorker_Join00
static int tolua_http_HttpWorker_Join00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HttpWorker",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HttpWorker* self = (HttpWorker*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Join'", NULL);
#endif
  {
   self->Join();
  }
 }
 return 0;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'Join'.",&tolua_err);
 return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE

/* Open function */
TOLUA_API int tolua_http_open (lua_State* tolua_S)
{
 tolua_open(tolua_S);
 tolua_reg_types(tolua_S);
 tolua_module(tolua_S,NULL,0);
 tolua_beginmodule(tolua_S,NULL);
  tolua_cclass(tolua_S,"HttpRequest","HttpRequest","",NULL);
  tolua_beginmodule(tolua_S,"HttpRequest");
   tolua_function(tolua_S,"get_uri",tolua_http_HttpRequest_get_uri00);
   tolua_function(tolua_S,"get_input_size",tolua_http_HttpRequest_get_input_size00);
   tolua_function(tolua_S,"Read",tolua_http_HttpRequest_Read00);
   tolua_function(tolua_S,"get_header",tolua_http_HttpRequest_get_header00);
   tolua_function(tolua_S,"get_host",tolua_http_HttpRequest_get_host00);
   tolua_function(tolua_S,"get_port",tolua_http_HttpRequest_get_port00);
   tolua_function(tolua_S,"get_path",tolua_http_HttpRequest_get_path00);
   tolua_function(tolua_S,"get_query",tolua_http_HttpRequest_get_query00);
  tolua_endmodule(tolua_S);
  tolua_cclass(tolua_S,"HttpResponse","HttpResponse","",NULL);
  tolua_beginmodule(tolua_S,"HttpResponse");
   tolua_function(tolua_S,"AddHeader",tolua_http_HttpResponse_AddHeader00);
   tolua_function(tolua_S,"Write",tolua_http_HttpResponse_Write00);
   tolua_function(tolua_S,"WritePrintf",tolua_http_HttpResponse_WritePrintf00);
   tolua_function(tolua_S,"End",tolua_http_HttpResponse_End00);
   tolua_function(tolua_S,"EndError",tolua_http_HttpResponse_EndError00);
  tolua_endmodule(tolua_S);
  #ifdef __cplusplus
  tolua_cclass(tolua_S,"HttpServer","HttpServer","",tolua_collect_HttpServer);
  #else
  tolua_cclass(tolua_S,"HttpServer","HttpServer","",NULL);
  #endif
  tolua_beginmodule(tolua_S,"HttpServer");
   tolua_function(tolua_S,"new",tolua_http_HttpServer_new00);
   tolua_function(tolua_S,"new_local",tolua_http_HttpServer_new00_local);
   tolua_function(tolua_S,".call",tolua_http_HttpServer_new00_local);
   tolua_function(tolua_S,"delete",tolua_http_HttpServer_delete00);
   tolua_function(tolua_S,"Start",tolua_http_HttpServer_Start00);
   tolua_function(tolua_S,"Stop",tolua_http_HttpServer_Stop00);
   tolua_function(tolua_S,"Run",tolua_http_HttpServer_Run00);
   tolua_function(tolua_S,"set_user_data",tolua_http_HttpServer_set_user_data00);
   tolua_function(tolua_S,"set_request_callback",tolua_http_HttpServer_set_request_callback00);
  tolua_endmodule(tolua_S);
  #ifdef __cplusplus
  tolua_cclass(tolua_S,"HttpWorker","HttpWorker","",tolua_collect_HttpWorker);
  #else
  tolua_cclass(tolua_S,"HttpWorker","HttpWorker","",NULL);
  #endif
  tolua_beginmodule(tolua_S,"HttpWorker");
   tolua_function(tolua_S,"new",tolua_http_HttpWorker_new00);
   tolua_function(tolua_S,"new_local",tolua_http_HttpWorker_new00_local);
   tolua_function(tolua_S,".call",tolua_http_HttpWorker_new00_local);
   tolua_function(tolua_S,"delete",tolua_http_HttpWorker_delete00);
   tolua_function(tolua_S,"Start",tolua_http_HttpWorker_Start00);
   tolua_function(tolua_S,"Join",tolua_http_HttpWorker_Join00);
  tolua_endmodule(tolua_S);
 tolua_endmodule(tolua_S);
 return 1;
}


#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
 TOLUA_API int luaopen_http (lua_State* tolua_S) {
 return tolua_http_open(tolua_S);
};
#endif

